home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_1.arc / WINDTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1988-09-10  |  2KB  |  84 lines

  1. { WindTest application in Turbo Pascal 4.0/5.0 by Tom Swan }
  2.  
  3. PROGRAM WindTest;
  4.  
  5.  
  6. USES  Crt, WindGlob;
  7.  
  8.  
  9. PROCEDURE WriteAt( x, y : Word; ch : Char );
  10.  
  11. { Display character ch at text display location (x,y) }
  12.  
  13. BEGIN
  14.    GotoXY( x, y );
  15.    Write( ch )
  16. END; { WriteAt }
  17.  
  18.  
  19. PROCEDURE DrawBox( left, top, right, bottom : Word );
  20.  
  21. { Outline a box on the text display }
  22.  
  23. VAR   i : Integer;      { FOR-loop control variable }
  24.  
  25. BEGIN
  26.    WriteAt( left, top, #213 );
  27.    WriteAt( right, top, #184 );
  28.    WriteAt( left, bottom, #192 );
  29.    WriteAt( right, bottom, #217 );
  30.    FOR i := left+1 TO right-1 DO
  31.    BEGIN
  32.       WriteAt( i, top, #205 );
  33.       WriteAt( i, bottom, #196 )
  34.    END; { for }
  35.    FOR i := top+1 TO bottom-1 DO
  36.    BEGIN
  37.       WriteAt( left, i, #179 );
  38.       WriteAt( right, i, #179 )
  39.    END { for }
  40. END; { DrawBox }
  41.  
  42.  
  43. PROCEDURE CenterTitle( s : String; left, top, right : Word );
  44.  
  45. { Center string s at row = top between left and right }
  46.  
  47. VAR   k : Integer;   { Spaces to offset title from left }
  48.  
  49. BEGIN
  50.    k := ( ( ( right - left ) + 1 ) - Length( s ) ) DIV 2;
  51.    GotoXY( left + k, top );
  52.    Write( s )
  53. END; { CenterTitle }
  54.  
  55.  
  56. PROCEDURE OpenWindow( left, top, right, bottom : Word; title : String );
  57.  
  58. { Display blank window, restricting subsequent text output to within
  59. the window's borders. }
  60.  
  61. BEGIN
  62.    TextColor( WBForeColor );
  63.    TextBackground( WBBackColor );
  64.    DrawBox( left, top, right, bottom );
  65.    CenterTitle( title, left, top, right );
  66.    Window( left+1, top+1, right-1, bottom-1 )
  67. END; { OpenWindow }
  68.  
  69.  
  70. BEGIN
  71.    ClrScr;
  72.    OpenWindow( 10, 3, 50, 12, WTitle );
  73.    TextColor( WTForeColor );
  74.    TextBackground( WTBackColor );
  75.    ClrScr;
  76.    WHILE NOT Keypressed DO
  77.    BEGIN
  78.       Delay( 15 );  { "Slow down, you move too fast..." }
  79.       Write( Chr( 32 + Random(144) ) )
  80.    END; { while }
  81.    Window( 1, 1, 80, 25 );
  82.    GotoXY( 1, 25 )
  83. END.
  84.